<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<base href="<%=request.getContextPath()%>/">
<link rel="stylesheet" href="about/css/bootstrap.min.css">
<link href="about/css/myCss.css" type="text/css" rel="stylesheet">
<link href="about/css/main.css" type="text/css" rel="stylesheet">
<link href="about/css/base.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="about/css/fullcalendar.css">
<!--按钮样式表-->
<link href="about/css/btn.css" type="text/css" rel="stylesheet">
<link href="about/css/css.css" type="text/css" rel="stylesheet">
<link href="about/css/index.css" type="text/css" rel="stylesheet">
<link href="about/css/search.css" type="text/css" rel="stylesheet">
<script src="about/js/jquery.min.js"></script>
<script src="about/js/bootstrap.min.js"></script>
<script src="about/js/common.js"></script>
<script type="text/javascript" src="about/js/fullcalendar.min.js"></script>
<title>护理记录</title>
<script type="text/javascript">
	function GetQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r != null)
			return unescape(r[2]);
		return null;
	}
	
	$(function() {
		$('.alertChart').click(function() {
			var url ="/api/nurrecord/recordList";
			var id=$(this).children('td').eq(2).text();
			var customerName = $(this).children('td').eq(3).text();
			var result;
			$.get(url,{
				"pageNo":"1",
				"pageSize":"5",
				"customerId":id,
				},
			function(resp){
					result=resp.data.rows;
				if(result.length>0){
					var html = printList(result,customerName,id);
					$("#body").html(html);
				}else{
					parentNoPage();
				}
			})
		});
	})

	var printList = function(result,customerName,customerId){
		var html = "";
		for(var i =0 ;i<result.length;i++){
			html+=printOnePage(result[i],i+1,customerName,customerId);
		}
		return html;
	}
	var printOnePage = function(result,index,customerName,customerId){
		var html = "<tr>";
			html+=">";
			html+="<td>"+index+"</td>";
			html+="<td>"+customerName+"</td>";
			html+="<td>"+result.nurContentName+"</td>";
			html+="<td>"+Date.format(result.startTime)+"</td>";
			html+="<td>1</td>";
			html+="<td>"+window.$$(result.content)+"</td>";
			html+="<td><a href='javascript:void(0);' onclick='sanchu("+customerId+","+result.nurContentId+")'><button class='btn btn-danger'>删除</button></a></td>";
			html+="</tr>";
			return html;
			
	}
	var parentNoPage = function(){
		var html= "<tr>";
		html+="<td colspan='999999'>没有查询记录</td></tr>";
		$("#body").html(html);
	}
	var sanchu = function (customerId,nurContentId) {
		var url ="/api/nurrecord/recordDelete";
		var id=$(this).children('td').eq(2).text();
		var customerName = $(this).children('td').eq(3).text();
		var result;
		$.get(url,{
			"customerId":customerId,
			"nurContentId":nurContentId,
			},
		function(resp){
				console.log(resp);
			if(resp.code==="ok"){
				toast("删除成功");
				setTimeout(function(){
					location.href="/beadhouse/nurrecord/customerList.do";
				},500)
			}else{
				toast(resp.message);
			}
		})
	}
	
	
	//此处分界
	//根据页面传参flag2只显示一条记录
	$(function() {
		//var temp = document.getElementsByName("flag2");
		var temp = GetQueryString("flag2");
		if (temp) {
			$('.alertChart').hide();
			$('.one_cwsyt').show();
		}
	})

	var _tableId = "";
	$(function() {
		$(".open_modal").bind("click", function() {
			$('#modal').modal('toggle');
		});

		// 绑定模态框展示的方法  
		$("#modal2").on("show.bs.modal", function(e) {
			// 获得点击打开的按钮  
			var button = $(e.relatedTarget)
			// 根据标签获得按钮传入的参数  
			//var recipient=button.data("table_id") 
			_tableId = button.data("table_id")
			
		})

	})
	function Cleanup() {
		window.clearInterval(idTmr);
		CollectGarbage();
	}
	var tableToExcel = (function() {
		var uri = 'data:application/vnd.ms-excel;base64,', template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>', base64 = function(
				s) {
			return window.btoa(unescape(encodeURIComponent(s)))
		}, format = function(s, c) {
			return s.replace(/{(\w+)}/g, function(m, p) {
				return c[p];
			})
		}
		return function(table, name) {
			if (!table.nodeType)
				table = document.getElementById(table)
				//table = document.getElementById(table)
			var ctx = {
				worksheet : name || 'Worksheet',
				table : table.innerHTML
			}
			//var ctx = {worksheet: name || 'Worksheet', table: '护理清单'}
			window.location.href = uri + base64(format(template, ctx))
		}
	})();

 	
</script>
</head>
<body>
	  <%-- <h5>${date.data.rows[0]}</h5>  --%>
	<div class="hlfxpg page">
		<div class="col-md-12 pd20 RightContentBody fmt10">
			<div class="col-md-3 pd0 fmt5">
				<div class="input-group inputWidth_search">
					<form action="nurrecord/customerList.do" style="display: flex;">
					<input type="text" name="key" class="form-control" placeholder="客户"> 
						<button class="btn btn-success">查询</button>
					</form>
				</div>
			</div>
			
			<div class="modal fade myModal1">
				<div class="modal-dialog">
					<div class="modal-content" style="width: 100%;">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<span class="glyphicon glyphicon-plus"></span>&nbsp;【添加-临时护理项目】
						</div>
						<div class="modal-body clearfix" style="height: auto;">
							<div class="col-md-12 pd0">
								<div class="col-md-1 pd0 mt10"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;客户：</span>
											<select class="form-control">
												<option>夏王玲</option>
												<option>王丽雅</option>
												<option>贾文</option>
											</select>
										</div>
									</div>
								</div>

								<div class="col-md-1 pd0"></div>
							</div>
							<div class="col-md-12 pd0 mt10">
								<div class="col-md-1 pd0"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;服务项目：</span>
											<select class="form-control">
												<option>测量血压</option>
												<option>吸氧</option>
											</select>
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							<div class="col-md-12 pd0 mt10">
								<div class="col-md-1 pd0"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;数量：</span>
											<input class="form-control">
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
							<div class="col-md-12 pd0 mt10">
								<div class="col-md-1 pd0"></div>
								<div class="col-md-10 pd0">
									<div class="col-md-12 pd0">
										<div class="input-group inputWidth">
											<span class="input-group-addon titleWidth">&nbsp;&nbsp;服务内容：</span>
											<input class="form-control">
										</div>
									</div>
								</div>
								<div class="col-md-1 pd0"></div>
							</div>
						</div>
						<div class="modal-footer mt20">
							<button type="button" class="btn btn-primary"
								data-dismiss="modal">确定</button>
							<button type="button" class="btn btn-default"
								data-dismiss="modal">取消</button>
						</div>
					</div>
				</div>
			</div>
			<!--<button class="btn btn-success" onclick="javascript:export_xls('hljl_hz')"><span class="glyphicon glyphicon-plus"></span>&nbsp;导出汇总表</button>-->
			<!--<button class="btn btn-success open_modal2"><span class="glyphicon glyphicon-plus"></span>&nbsp;导出清单</button>-->
			<div class="col-md-12 pd0 fmt10">
				<hr class="commonHRCss" />
			</div>
			<div class="col-md-4 pd0"
				style="border: 1px solid; border-color: #d4c5c5;">
				<div style="height: 50px; background-color: #3CA2E0;"
					class="col-md-12 pd0">
					<div class="col-md-12 mt10 pd0 GZTXX_Content_Table_Head_Font">
						<div class="col-md-1 text-center pd0 mt2">
							<span class="glyphicon glyphicon-user"></span>
						</div>
						<div class="col-md-11 pd0">客户列表</div>
					</div>
				</div>
				<table class="table table-hover">
					<thead>
						<tr>
							<th></th>
							<th>序号</th>
							<th hidden>id</th>
							<th>姓名</th>
							<th>性别</th>
							<th>年龄</th>
							<th>护理级别</th>
							<th>护理内容</th>
						</tr>
					</thead>
					<tbody>
						<c:if test="${date.data.pageNo!=date.data.totalPages}">
						<c:forEach var="i" begin="0" end="${date.data.pageSize-1}" step="1">
						<tr class="alertChart one_cwsyt">
								<td><input type="checkbox"></td>
								<td>${i+1}</td>
								<td hidden>${date.data.rows[i].customerId}</td>
								<td class="select">${date.data.rows[i].customerName}</td>
								<c:if test="${date.data.rows[i].customerSex}">
									<td>男</td>
								</c:if>
								<c:if test="${!date.data.rows[i].customerSex}">
									<td>女</td>
								</c:if>
								<td>${date.data.rows[i].customerAge}</td>
								<td>${date.data.rows[i].nurLevelName}</td>
								<td><a href="nurrecord/projectList.do?nurLevelId=${date.data.rows[i].nurLevelId}&customerId=${date.data.rows[i].customerId}">
										<button class="btn btn-success">今日护理</button>
								</a></td>
							</tr>
						</c:forEach>
						</c:if>
						
						<c:if test="${date.data.pageNo==date.data.totalPages}">
						<c:forEach var="i" begin="0" end="${date.data.totalRows-(date.data.totalPages-1)*date.data.pageSize-1}" step="1">
						<tr class="alertChart one_cwsyt">
								<td><input type="checkbox"></td>
								<td>${i+1}</td>
								<td hidden>${date.data.rows[i].customerId}</td>
								<td class="select">${date.data.rows[i].customerName}</td>
								<c:if test="${date.data.rows[i].customerSex}">
									<td>男</td>
								</c:if>
								<c:if test="${!date.data.rows[i].customerSex}">
									<td>女</td>
								</c:if>
								<td>${date.data.rows[i].customerAge}</td>
								<td>${date.data.rows[i].nurLevelName}</td>
								<td><a href="nurrecord/projectList.do?nurLevelId=${date.data.rows[i].nurLevelId}&customerId=${date.data.rows[i].customerId}">
										<button class="btn btn-success">今日护理</button>
								</a></td>
							</tr>
						</c:forEach>
						</c:if>
					</tbody>
				</table>
				<div class="col-md-12 pd0">
					<div class="col-md-12 text-right pd0 fmt20">
						<nav aria-label="Page navigation">
							<ul class="pagination">
								<li><a href="javaScript:void(0);"> <span
										aria-hidden="true">&laquo;</span>
								</a></li>
								<c:forEach var="i" begin="1" end="${date.data.totalPages}" step="1">
									<li><a href="nurrecord/customerList.do?
									pageNo=${i}&pageSize=${date.data.pageSize}">${i}</a></li>
								</c:forEach>
								<li><a href="javaScript:void(0);"> <span
										aria-hidden="true">&raquo;</span>
								</a></li>
							</ul>
						</nav>
					</div>
				</div>
			</div>
			<div class="col-md-8 pd0">
				<div class="col-md-12 pd0"
					style="margin-left: 5px; border: 1px solid; border-color: #d4c5c5;">
					<div style="height: 50px; background-color: #3CA2E0;"
						class="col-md-12 pd0">
						<div class="col-md-12 mt10 pd0 GZTXX_Content_Table_Head_Font">
							<div class="col-md-1 text-center pd0 mt2">
								<span class="glyphicon glyphicon-list"></span>
							</div>
							<div class="col-md-11 pd0">护理记录</div>
						</div>
					</div>
					<table id="hljl" class="table table-hover">
						<thead>
							<tr>
								<th>序号</th>
								<th>客户姓名</th>
								<th>护理项目</th>
								<th>护理时间</th>
								<th>数量</th>
								<th>护理内容</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="body">
							
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>

	<!-- 模态框 -->
	
	<div class="modal fade" id="modal2" role="dialog"
		aria-label="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content" style="width: 100%;">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<span class="glyphicon glyphicon-list"></span>&nbsp;请选择时间段 下载数据
				</div>
				<div class="modal-body clearfix" style="height: auto;">
					<div class="col-md-12 pd0">
						<div class="col-md-1 pd0 mt10"></div>
						<div class="col-md-10 pd0">
							<div class="col-md-12 pd0">
								<div class="input-group inputWidth">
									<span class="input-group-addon titleWidth">&nbsp;&nbsp;开始时间：</span>
									<input type="date" class="form-control">
									<!--<input class="form-control" type="text">-->
								</div>
							</div>
						</div>
						<div class="col-md-1 pd0"></div>
					</div>
					<div class="col-md-12 pd0 mt10">
						<div class="col-md-1 pd0"></div>
						<div class="col-md-10 pd0">
							<div class="col-md-12 pd0">
								<div class="input-group inputWidth">
									<span class="input-group-addon titleWidth">&nbsp;&nbsp;结束时间：</span>
									<input type="date" class="form-control">
								</div>
							</div>
						</div>
						<div class="col-md-1 pd0"></div>
					</div>
				</div>
				<div class="modal-footer mt20">
					<!--<button type="button" class="btn btn-primary" onclick="javascript:export_xls('hljl')">确定</button>-->
					<button type="button" class="btn btn-primary" data-dismiss="modal"
						onclick="javascript:export_xls()">确定</button>
					<button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="modal_ap" role="dialog"
		aria-label="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content" style="width: 200%; margin-left: -230px;">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<span class="glyphicon glyphicon-cog"></span>&nbsp;护理安排
				</div>
				<div class="modal-body clearfix" style="height: auto;">
					<div id='calendar'
						style="width: 100%; height: 800px; margin: 20px auto 10px auto;"></div>
				</div>
				<div class="modal-footer mt20">
					<button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="add_schedule" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">护理安排</h4>
				</div>
				<div class="modal-body">
					<form id="form_schedule" class="form-horizontal form-label-left">
						<div class="form-group">
							<label class="control-label col-md-4 col-sm-4 col-xs-12"
								for="type">护理项目：</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<select name="type" class="form-control">
									<option value="测量血压">测量血压</option>
									<option value="协助吃药">协助吃药</option>
									<option value="翻身">翻身</option>
									<option value="洗头">洗头</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4 col-sm-4 col-xs-12"
								for="start">护理内容：</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input class="form-control" />
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4 col-sm-4 col-xs-12"
								for="start">开始时间：</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input id="date_start" type="datetime-local" name="start"
									class="form-control">
							</div>
						</div>
						<div id="end" class="form-group">
							<label class="control-label col-md-4 col-sm-4 col-xs-12"
								for="end">结束时间：</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input id="date_end" type="datetime-local" name="end"
									class="form-control">
							</div>
						</div>
						<div id="location" class="form-group" style="display: none;">
							<label class="control-label col-md-4 col-sm-4 col-xs-12"
								for="location">地 点：</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input type="text" name="location" class="form-control">
							</div>
						</div>
						<div id="reason" class="form-group" style="display: none;">
							<label class="control-label col-md-4 col-sm-4 col-xs-12"
								for="reason">事 由：</label>
							<div class="col-md-6 col-sm-6 col-xs-12">
								<input type="text" name="reason" class="form-control">
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button id="button_delete_schedule" type="button"
						class="btn btn-danger" style="float: left;">删除</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭窗口</button>
					<button id="button_save_schedule" type="button"
						class="btn btn-primary">提交</button>
				</div>
			</div>
		</div>
	</div>

	<table id="hljl_hz" hidden="hidden">
		<thead>
			<tr>
				<th>序号</th>
				<th>客户姓名</th>
				<th>护理项目</th>
				<th>护理时间</th>
				<th>数量</th>
				<th>护理内容</th>
				<th>护理人员</th>
			</tr>
		</thead>
		<tbody>
			
		</tbody>
	</table>
</body>
</html>
